package com.gss.plugin.doc.properties;

import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.List;

/**
 * @author: DYang
 * @since: 2023/8/17
 * @description: swagger-Knife4j 配置
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "knife4j")
public class Knife4jProperties {

    /**
     * 是否开启Knife4j增强模式
     */
    @Value("${knife4j.enable:true}")
    private boolean enable=true;
    /**
     * 是否开启默认跨域
     */
    @Value("${knife4j.cors:true}")
    private boolean cors=true;

    /**
     * 项目名称
     */
    @Value("${spring.application.name}")
    private String projectName;

    /**
     * 是否启用oauth2 security模式，默认不开启
     */
    @Value("${knife4j.securityMode:false}")
    private boolean securityMode = false;
    /**
     * 存储接口到数据库，默认开启
     */
    @Value("${knife4j.enableSaveDb:true}")
    private boolean enableSaveDb = true;
    /**
     * 新增到数据库表sql
     */
    private String insertApiSql =
            "   INSERT INTO sys_menu(menu_name,menu_type,route,url,create_time, update_time)\n" +
            "   VALUES (?,?,?,?,NOW(),NOW())\n" +
            "   ON CONFLICT (url) DO UPDATE\n" +
            "   SET update_time=NOW()" +
            "\n";
    /**
     * 安全认证信息
     */
    private List<SecurityBasic> securityBasics;

    /**
     * 安全认证信息
     */
    @Data
    public static class SecurityBasic{
        /**
         * 可用范围
         */
        private String scope;
        /**
         * 用户名
         */
        private String name;
        /**
         * 密码
         */
        private String password;
        /**
         * 认证方式：password,
         */
        private String grantType = "password";
        /**
         * token检测url
         */
        private String tokenUrl = "http://localhost:8080/auth/oauth/token";

    }

}
